{% extends 'base.html' %}

{% block title %}登录 - AI故事生成系统{% endblock %}

{% block content %}
<div class="container">
    <div class="row justify-content-center">
        <div class="col-md-6">
            <div class="card">
                <div class="card-header">
                    <h3 class="card-title">用户登录</h3>
                </div>
                <div class="card-body">
                    <form method="post" novalidate>
                        {% csrf_token %}
                        <input type="hidden" name="csrfmiddlewaretoken" value="{{ csrf_token }}">
                        <div class="mb-3">
                            <label for="{{ form.username.id_for_label }}" class="form-label">用户名</label>
                            <input type="text" name="username" class="form-control {% if form.username.errors %}is-invalid{% endif %}" 
                                   id="{{ form.username.id_for_label }}" value="{{ form.username.value|default:'' }}" required>
                            {% if form.username.errors %}
                            <div class="invalid-feedback">
                                {{ form.username.errors|join:", " }}
                            </div>
                            {% endif %}
                        </div>
                        <div class="mb-3">
                            <label for="{{ form.password.id_for_label }}" class="form-label">密码</label>
                            <input type="password" name="password" class="form-control {% if form.password.errors %}is-invalid{% endif %}" 
                                   id="{{ form.password.id_for_label }}" required>
                            {% if form.password.errors %}
                            <div class="invalid-feedback">
                                {{ form.password.errors|join:", " }}
                            </div>
                            {% endif %}
                        </div>
                        {% if form.non_field_errors %}
                        <div class="alert alert-danger">
                            {% for error in form.non_field_errors %}
                            {{ error }}
                            {% endfor %}
                        </div>
                        {% endif %}
                        <div class="d-grid gap-2">
                            <button type="submit" class="btn btn-primary">登录</button>
                            <a href="{% url 'user:register' %}" class="btn btn-outline-secondary">没有账号？注册</a>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>
{% endblock %} 